﻿//using ZPeng.CppPro.Model.Log;

namespace ZPeng.CppPro.Model.Log
{
    public class LogFactory
    {
        public static string DefaultName = "ProgramLog";

        private static List<SimpleLog> _instanceList;
        public static SimpleLog GetLogInstance(string name)
        {
            if (_instanceList == null)
            {
                _instanceList = new List<SimpleLog>();
            }
            var obj = _instanceList.Find(t => t.InstanceName == name);
            if (obj == null)
            {
                obj = new SimpleLog(name);

                _instanceList.Add(obj);
            }

            return obj;
        }

        // 等待所有日志模块结束
        public static void WaitAllLogWriten()
        {
            foreach (var item in _instanceList)
            {
                item.WriteForWritten();
            }
        }
    }
}
